#ifndef _VN_COLLISION_LISTENER_H_
#define _VN_COLLISION_LISTENER_H_

#include "Box2D\Box2D.h"
#include <map>

class CollisionListener : public b2ContactListener
{
public:
	CollisionListener(void);
	virtual ~CollisionListener(void);

	void BeginContact(b2Contact*);
	void EndContact(b2Contact*);

	typedef void (CollisionListener::*HitFuncPtr)(void*, void*);
	typedef std::map<std::pair<int, int>, HitFuncPtr> HitMap;
	std::pair<int, int> makeIntPair(int, int);

	// Begin Contact collision methods
	// Primary collision processing
	void playerSensorGroundFloor(void* p_playerSensorGround, void* p_floor);
	void projectileHitFloor(void* p_projectileHit, void* p_floor);
	void enemyHitPlayer(void* p_enemy, void* p_player);
	void playerProjectileEnemy(void* p_playerProjectile, void* p_enemy);

	// Secondary collision processing
	void floorPlayerSensorGround(void* floor, void* playerSensorGround) { playerSensorGroundFloor(playerSensorGround, floor); }
	void floorHitProjectile(void* floor, void* projectileHit) { projectileHitFloor(projectileHit, floor); }
	void playerHitEnemy(void* player, void* enemyHit) { enemyHitPlayer(enemyHit, player); }
	void enemyPlayerProjectile(void* p_enemy, void* p_playerProjectile) { playerProjectileEnemy(p_playerProjectile, p_enemy); }

	// End Contact collision methods (primary)
	void playerSensorGroundFloorEnd(void* p_playerSensorGround, void* p_floor);

	// Secondary
	void floorPlayerSensorGroundEnd(void* floor, void* playerSensorGround) { playerSensorGroundFloorEnd(playerSensorGround, floor); }

protected:
	inline void initCollisionMaps();
	HitMap m_beginContactCollisionMap;
	HitMap m_endContactCollisionMap;
};

#endif // _VN_COLLISION_LISTENER_H_